package com.stefanini.worldcupinformation.controladores.administrator;

import com.stefanini.worldcupinformation.ejbs.GroupDao;
import com.stefanini.worldcupinformationpersistence.entities.Grupo;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;

@Named("mainAdministratorController")
@SessionScoped
public class MainAdministratorController implements Serializable{
    private static final long serialVersionUID = 1L;
    
    @EJB
    private GroupDao groupDao;
    
    private List<Grupo> groups;
    
    public void goToviewNewGroup(){
        try {
            FacesContext.getCurrentInstance().getExternalContext().redirect(
                    "/worldCupInformation/pages/groups/newGroup.xhtml");
        } catch (IOException ex) {
            Logger.getLogger(MainAdministratorController.class.getName()).log(Level.SEVERE, 
                    "Error redireccionando a newGroup.xhtml", ex);
        }
    }
    
    public void init(){
        this.groups = this.groupDao.getAll();
    }

    public List<Grupo> getGroups() {
        return groups;
    }
    
}
